#include <iostream>
#include <cstdlib>
using namespace std;
#define N 8
struct node
{
    int v;
    node *next;
    node(int x,node *t):v(x),next(t){ }
};
typedef node *Link;

int main()
{
    freopen("input.txt","r",stdin);
    int i,j;
    Link adj[N];
    for(i=0;i<N;i++) adj[i]=0;
    while(cin>>i>>j)
    {
        adj[j]=new node(i,adj[j]);
        adj[i]=new node(j,adj[i]);
    }

    for(i=0;i<N;i++)
    {
        cout<<i<<"\t";
        while(adj[i]->next!=NULL)
        {
            cout<<adj[i]->v<<"--->";
            adj[i]=adj[i]->next;
        }
        cout<<adj[i]->v<<endl;

    }



}